package com.cykj.controller;

import com.cykj.dto.ResponseDto;
import com.cykj.pojo.PsUser;
import com.cykj.service.UserService;
import com.cykj.vo.QueryUser;
import com.cykj.vo.UserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @BelongsProject: Psychology
 * @BelongsPackage: com.cykj.controller
 * @Author: 小林
 * @CreateTime: 2025-01-17 20:36
 * @Description: 用户表
 * @Version: 1.0
 */
@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;

    /**
     * 获取全部
     * @param vo
     * @return
     */
    @RequestMapping("/getAll")
    public ResponseDto getAll(@RequestBody QueryUser vo){
        return userService.getAll(vo);
    }

    /**
     * 通过id去获取对应信息
     * @param id
     * @return
     */
    @RequestMapping("/getId")
    public PsUser getId(Integer id){
        return userService.getUserById(id);
    }

    /**
     * 修改状态
     * @param id
     * @param status
     * @return
     */
    @RequestMapping("/updateUserStatus")
    public ResponseDto updateUserStatus(Integer id,  Integer status){
        return userService.updateUserStatus(id, status);
    }

    /**
     * 重置密码
     * @param id
     * @param newPassword
     * @return
     */
    @RequestMapping("/resetPassword")
    public ResponseDto resetPassword(Integer id, String newPassword){
         newPassword = "123456";
        return userService.resetPassword(id, newPassword);
    }

    /**
     * 修改用户状态
     * @param id
     * @param userDelete
     * @return
     */
    @RequestMapping("/updateUserDelete")
    public ResponseDto updateUserDelete(Integer id, Integer userDelete){
        return userService.updateUserDelete(id, userDelete);
    }

    // 获取七天内的用户注册量
    @RequestMapping("/getRegisterCountInSevenDays")
    public ResponseDto getRegisterCountInSevenDays() {
        return userService.getRegisterCountInSevenDays();
    }

    // 获取本月每周的用户注册量
    @RequestMapping("/getRegisterCountInOneMonth")
    public ResponseDto getRegisterCountInOneMonth() {
        return userService.getRegisterCountInOneMonth();
    }

    // 获取近半年每月的用户注册量
    @RequestMapping("/getRegisterCountInHalfYear")
    public ResponseDto getRegisterCountInHalfYear() {
        return userService.getRegisterCountInHalfYear();
    }

    /**
     * 用户扣费
     * @param vo
     * @return
     */
    @RequestMapping("/deductions")
    public ResponseDto deductions(@RequestBody UserVo vo){
        return userService.deductions(vo);
    }

    /**
     * 充值
     * @param vo
     * @return
     */
    @RequestMapping("/addMoney")
    public ResponseDto addMoney(@RequestBody UserVo vo){
        return userService.addMoney(vo);
    }

    /**
     * 查询用户余额
     * @param vo
     * @return
     */
    @RequestMapping("/selectUserBalance")
    public ResponseDto selectUserBalance(@RequestBody UserVo vo){
        return userService.selectUserBalance(vo);
    }
}

